<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class SuccessController extends Controller
{
   public function getIndex(){
  
    return view('/home/success/index');
   }

   public function postSend(Request $request){
    //获取id
    $id = $request -> only('uid');  
    foreach($id as $v){}
    $data = DB::table('address')->where('id','=',$id)->first();

    $rand = (100000+rand(10000,99999));
    $id =$request ->except(['_token','address2','say','dollar','country','town','uid','province']);
    if(empty($data)){
      return back();
    }else{
       $date['pid'] = $rand;
       $date['state'] = '2';
       $date['ctime'] = date("F j, Y, g:i a");
       $date['uid'] = $v;
    } 
    $datas = DB::table('address')
           ->join('order','address.uid','=','order.uid')
           ->select('address.name','address.tel')
           ->get();
      foreach($datas as $val){}
        $date['name'] = $val['name'];
         $date['tel'] = $val['tel'];
       DB::table('order')->insert($date);    
    return view('/home/success/index',['data' => $data]);
   }  
}
